﻿using Furion.DatabaseAccessor;
using System;
using System.ComponentModel.DataAnnotations;
using YFurion.Locators;

namespace YFurion.Entities
{
    [Serializable]
    public abstract class CMEntity : CMEntityOfTKey<long>, IYEntity, IAudited
    {
        [Key]
        public override long Id { get; set; }
    }

    [Serializable]
    public abstract class CMEntity<TDbContextLocator1, TDbContextLocator2> :
        CMEntityOfTKey<long, TDbContextLocator1, TDbContextLocator2>,
        IYEntity<TDbContextLocator1, TDbContextLocator2>,
        IAudited
        where TDbContextLocator1 : class, IDbContextLocator
        where TDbContextLocator2 : class, IDbContextLocator
    {
        [Key]
        public override long Id { get; set; }
    }

    [Serializable]
    public abstract class CMEntityOfTKey<TKey> : CMEntityOfTKey<TKey, MasterDbContextLocator, SlaveDbContextLocator>, IYEntityOfTKey<TKey>, IAudited<TKey>
    {
    }

    [Serializable]
    public abstract class CMEntityOfTKey<TKey, TDbContextLocator1, TDbContextLocator2> : CMEntityBase<TKey>,
        IYEntityOfTKey<TKey, TDbContextLocator1, TDbContextLocator2>,
        IAudited<TKey>
        where TDbContextLocator1 : class, IDbContextLocator
        where TDbContextLocator2 : class, IDbContextLocator
    {
    }

    [Serializable]
    public abstract class CMEntityBase<TKey> : CEntityBase<TKey>, IAudited<TKey>
    {
        public virtual TKey LastModifierUserId { get; set; }

        public virtual DateTime? LastModificationTime { get; set; }
    }
}
